package com.cy.interceptor;

import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalTime;
@RestControllerAdvice
public class TimeAccessInterceptors implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        if(LocalTime.now().getHour()<20)throw  new RuntimeException("请在规定时间访问");
        return false;
    }
}
